home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
CUGUK
/
PROG_TOO
/
C013.ZIP
/
CHMOD.C
< prev
next >
Wrap
Text File
|
1990-01-19
|
2KB
|
66 lines
/********************************************************************
* C Users Group (U.K) C Source Code Library File CUGLIB.013 *
* Inquiries to: M. Houston, 36 Whetstone Clo. Farquhar Rd. *
* Edgbaston, Birmingham B15 2QN ENGLAND *
********************************************************************
* File name: chmod.c
* Program name:chmod
* Source of file: Ron Wellstead
* Purpose: An MS-DOS copy of the UNIX utility of the same name.
* Changes: <who what when & why major changes have been made>
********************************************************************/
/*
*
* @(#) chmod.c 1.2 87/07/27
*
* UNIX style chmod utility for dos
*
* copyright (c) 1987 Ron Wellsted.
* This software is provided on the understanding that it is
* NOT to be used for commercial gain. It may be freely distributed
* in source or object form among amateur and hobby computer users ONLY!
*
* changes mode (write access) of files
* usage: chmod {+/-} files....
* Written for Microsoft C, link with setargv.obj to expand wildcards
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
char buffer[]="@(#)chmod VR 1.0.0 15 Jul 1987";
main(argc,argv)
int argc;
char *argv[];
{
char *ptr;
int i,mode;
if (argc>=3)
{
ptr=argv[1];
ptr++;
if ((*argv[1]=='-')&&(tolower(*ptr)=='w')) mode=S_IREAD;
else if ((*argv[1]=='+')&&(tolower(*ptr)=='w')) mode=S_IWRITE;
else mode=0;
}
if ((argc<3)||(mode==0))
{
fprintf(stderr,"usage: chmod +|-w file1 [.... fileN]\n");
exit(1);
}
for (i=2;i<argc;i++)
{
if (chmod(argv[i],mode))
{
fprintf(stderr,"chmod: ");
perror(argv[i]);
exit(1);
}
}
exit(0);
}